//
//  CommisstionVc.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/6/5.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "CommisstionVc.h"
#import "BdTV.h"
#import "DealerDataManage.h"
#import "API.h"
#import "MBProgressHUD+MJ.h"
#import "CommissionViewPage.h"
#import "StoreCommissionVc.h"
#import "BrokerCommissionListVc.h"


@interface CommisstionVc ()
@property (weak, nonatomic) IBOutlet UILabel *allCountLab;
@property (weak, nonatomic) IBOutlet UILabel *passCountLab;
@property (weak, nonatomic) IBOutlet UILabel *futureCountLab;
@property (weak, nonatomic) IBOutlet UIButton *btn1;
@property (weak, nonatomic) IBOutlet UIButton *btn2;
@property (weak, nonatomic) IBOutlet UIButton *btn3;



@property (strong, nonatomic) DealerDataManage *dm;

@end

@implementation CommisstionVc
@synthesize dm;


- (void)viewDidLoad {
    [super viewDidLoad];


    [self initView];
    
    
    [self refreshData];
    
}



-(void)initView{
    [super initView];
    
    BdTV *title = [BdTV creatInstanceWithTitle:@"佣金管理"];
    [title.backBtn setTag:11];
    [title.backBtn addTarget:self action:@selector(btnOnclick:) forControlEvents:UIControlEventTouchUpInside];
    [[title doneBtn] removeFromSuperview];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:title];
    
    [self.btn1 addTarget:self action:@selector(btnOnclick:) forControlEvents:UIControlEventTouchUpInside];
    [self.btn2 addTarget:self action:@selector(btnOnclick:) forControlEvents:UIControlEventTouchUpInside];
    [self.btn3 addTarget:self action:@selector(btnOnclick:) forControlEvents:UIControlEventTouchUpInside];
    
    dm = [DealerDataManage new];
}

-(void)refreshData{
    
    
    __weak typeof(self) baseSelf = self;
    [MBProgressHUD showMessage:LOADING toView:self.view];
    [dm refreshYongJinDataTableIndex:Commission_tab0 withParm:[NSMutableDictionary new] CallBack:^(ResulteMod *resultMod) {
       
        [MBProgressHUD hideHUDForView:baseSelf.view animated:YES];
        
        if(resultMod.resltState==ResultNetError){
        
            [MBProgressHUD showError:NET_ERROR];
            
        }else if (resultMod.resltState==ResultFail){
        
            [MBProgressHUD showError:[NSString stringWithFormat:@"%@:%@",NET_ERROR,resultMod.resultCode]];
            
        }else{
            
            CommissionData *headData = resultMod.dataMod;
            
            [baseSelf.allCountLab setText:headData.saleMoneryCount];
            
            [baseSelf.passCountLab setText:headData.passCommissionMoneryCount];
            [baseSelf.futureCountLab setText:headData.unPassCommissionMoneryCount];
        }
    }];
}



-(void)btnOnclick:(UIButton*)sender{
    
    if (sender==self.btn1) {
        
         self.hidesBottomBarWhenPushed = YES;
        CommissionViewPage *vp = [[CommissionViewPage alloc]init];
         vp.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vp animated:YES];
        
    }else if (sender==self.btn2){
        
        StoreCommissionVc *vc = [StoreCommissionVc new];
         vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
        
    }else if (sender==self.btn3){
        BrokerCommissionListVc *vc = [BrokerCommissionListVc new];
         vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
        
    }else if (sender.tag==11){
        [self.navigationController popViewControllerAnimated:YES];
    }
}


@end
